package eclipse.lib.sound;
import javax.swing.*;
public class AudioTest extends JApplet
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7591975153095529449L;
	private String fixParameter(String param)
	{
		if(param == null)
			return param;
		param = param.replace("%3A", ":");
		param = param.replace("%2F", "/");
		param = param.replace("%7E", "~");
		return "";
	}
	public void init()
	{
		
		String song = getParameter("song");
		String loop = getParameter("loop");
		song = fixParameter(song);
		loop = fixParameter(loop);
		System.out.println("song: " + song);
		System.out.println("loop: " + loop);
				
		AudioDevice audio = new AudioDevice();
		if(song == null)
		{
			System.exit(0);
			return;
		}
		audio.loadAudio(song);
		if(loop.toLowerCase().equals("true"))
			audio.loopAudio();
		else
			audio.playAudio();			
	}
	public static void main(String args[])
	{
		try
		{
			AudioDevice audioHandler = new AudioDevice();
			audioHandler.loadAudio("jar://forshadows.mp3");
			audioHandler.loopAudio();
		}
		catch(Exception e)
		{
			eclipse.ErrorManager.handleError(e);
		}
	}
}
